#ifndef _GAMEPLAYER_H_
#define _GAMEPLAYER_H_


#include "GameCreature.h"
#include "GamePet.h"
#include "ItemBag.h"
#include "netSocket.h"


class GamePlayer : public GameCreature
{
public:

	GamePlayer();
	virtual ~GamePlayer();

	fvoid					SendMsgToTeam();
	fvoid					SendMsg();
	fvoid					PackMsg( netMsgHead* msg );

	fvoid					SetSocket( netSocket* socket );
	netSocket*              GetSocket();

	virtual fvoid			Init();
	fvoid					Release();

	fbool					IsValid()
	{
		if ( mSocket )
		{
			if ( mSocket->IsVaild() && mValid )
			{
				return F_TRUE;
			}
		}
		
		return F_FALSE;
	}

	fvoid					SetValid( fbool b )
	{
		mValid = b;
	}

	virtual fvoid			EndFight();

	//////////////////////////////////////////////////////////////////////////

	fvoid					SetAttackPet( GamePet* pet )
	{
		mAttackPet = pet;
	}

	GamePet*				GetAttackPet()
	{
		return mAttackPet;
	}

	GamePetMap&				GetPetMap()
	{
		return mPet;
	}

	GamePetMap&				GetPetAtHomeMap()
	{
		return mPetAtHome;
	}

	GamePet*				GetPet( fint32 id );

	fvoid					SetPetName( fint32 id , const fbyte* name );
	fvoid					SetPetType( fint32 id , fint32 type );

	//////////////////////////////////////////////////////////////////////////
	
	fvoid					LevelUpPoint( fint32 type );


	//////////////////////////////////////////////////////////////////////////

	virtual fvoid			UpdateFightData();

	ItemBag&				GetItemBag();

	fbool					UseItem( fint32 i , fint32 p , fint32 t );
	fvoid					EquipItem( fint32 i );

	fvoid					SwitchItem( fint32 i1 , fint32 i2 );
	fvoid					DropEquip( fint32 i1 , fint32 i2 );
	fvoid					SwitchEquip( fint32 i1 , fint32 i2 );

	virtual fvoid			AddHp( fint32 hp );
	virtual fvoid			AddMp( fint32 mp );

	fvoid					Heal( fint32 mode );

	//////////////////////////////////////////////////////////////////////////

	fbool					CheckStone( fint32 stone );
	fvoid					IncreaseStone( fint32 stone );
	fvoid					DecreaseStone( fint32 stone );
	fint32					mStone;


	//////////////////////////////////////////////////////////////////////////

	fbyte					Account[ MAX_NAME ];

    //////////////////////////////////////////////////////////////////////////
    
    fvoid                   UpdateSyncMove();
    fvoid                   SendMsgToAll( netMsgHead* msg , fint32 self = INVALID_ID );
    fvoid                   SendMsgToAllEE( netMsgHead* msg , fint32 self = INVALID_ID );
    
protected:

	ItemBag					mItemBag;

	GamePet*				mAttackPet;
	GamePetMap				mPet;
	GamePetMap				mPetAtHome;

	fbool					mValid;

	fint32					mSQLCount;

	netSocket*              mSocket;

};


typedef list< GamePlayer* > GamePlayerList;
typedef list< GamePlayer* >::iterator GamePlayerListIter;

#endif

